package com.boot.controller;

import com.boot.DTO.SetmealDAO;
import com.boot.Vo.SetmealVo;
import com.boot.result.Result;
import com.boot.service.SetmealService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @Operation(summary = "新增套餐")
    @PostMapping()
    public Result addSetmeal(@RequestBody SetmealDAO setmealDAO) {
        return setmealService.addSetmeal(setmealDAO);
    }

    @Operation(summary = "分页获取套餐数据")
    @GetMapping("page")
    public Result getSetmealPage(SetmealVo setmealVo) {
        return setmealService.getSetmealPage(setmealVo);
    }

    @Operation(summary = "套餐起售、停售")
    @PostMapping("status/{status}")
    public Result updateSetmealStatus(@PathVariable("status") String status,@Parameter(required = true) Long id) {
        return setmealService.updateSetmealStatus(id, status);
    }

    @Operation(summary = "根据id查询套餐")
    @GetMapping("{id}")
    public Result getSetmealById(@PathVariable Long id) {
        return setmealService.getSetmealById(id);
    }

    @Operation(summary = "修改套餐")
    @PutMapping
    public Result updateSetMeal(@RequestBody SetmealDAO setmealDAO) {
        return setmealService.updateSetMeal(setmealDAO);
    }

    @Operation(summary = "批量删除")
    @DeleteMapping
    public Result deleteSetmeal(@Parameter(required = true) Long[] ids) {
        return setmealService.deleteSetmeal(ids);
    }

}
